'use strict'

import HybridJS from '../core/core'

const $ = HybridJS

/**
 * 设置badge文字，当文字为为空字符串时，将显示一个小红点,传 null 时，badge隐藏
 */
function setBadge(text) {
    return $.callNativeSync("tab","setBadge",{text:text})
}

/**
 * 设置badge数字
 */
function setBadgeNum(num,max,maxStr) {
    var text = num <= max ? num + '' : maxStr
    if (num == 0) {
        text = null
    }
    return $.callNativeSync("tab","setBadge",{text:text})
}

/**
 * 跳转到其他tab页
 */
function to(index) {
    return $.callNativeSync("tab","to",{index:index})
}

export default {
    setBadge,
    setBadgeNum,
    to
}